<template>
  <div>
    <el-table :data="billList" :border="false" stripe  align="left">
      <el-table-column property="partnerName" :label="pageType == 'parking' ? '被委托方' : '客户'"></el-table-column>
      <el-table-column property="contractName" label="合同名称"></el-table-column>
      <el-table-column label="起止时间">
        <template slot-scope="scope">
            {{scope.row.contractBeginDate | date-format('YYYY-MM-DD')}}
            <span>至</span>
            {{scope.row.contractEndDate | date-format('YYYY-MM-DD')}}
        </template>
      </el-table-column>
      <!-- <el-table-column align="left" label="合同总价">
        <template slot-scope="scope">
          <span>{{ scope.row.contractTotalAmount | moneyFilterNoUnit }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="100" header-align="center" align="center">
        <template slot-scope="scope">
          <el-button @click="handleView(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import { requestTips, askDialog } from '@js/utils';
  import { formValid } from '@/lib/utils';
  import {apiContractHistoryList} from '@a/about';

  export default {
    props: {
      model: {
        type: Object,
        default: null,
      },
      pageType: {
        type: String,
        default: '',
      },
    },

    data() {
      return {
        billList:[]
      };
    },

    mounted() {
      this.getDataSource();
    },

    methods: {
      async getDataSource() {
        let res = await apiContractHistoryList({ contractKey: this.model.contractKey, assetCode: this.model.code, contractCode: this.model.contractCode });
        this.billList = res.rows || [];
      },

      handleView(row){
        let param = {
          contractType: row.contractType,
          contractCode: row.contractCode,
          contractKey: row.primaryKey,
          contractCategory: row.contractCategory,
          headerName:"合同管理"
        };
        
        let pathName = '/businessAssets/ContractManage/info?';
        for (let i in param) {
          pathName += i + '=' + param[i] + '&';
        }
        window.open(pathName);
      }
    },
  };
</script>
<style lang="scss" scoped>
  .flex-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  ::v-deep .el-table th.el-table__cell.is-leaf {
    background: #f1f1f1;
  }
  ::v-deep .el-table td.el-table__cell,
  .el-table th.el-table__cell.is-leaf {
    border: none;
  }
  ::v-deep .el-table thead .cell {
    font-size: 14px;
  }
</style>
